//
//  ProtocolConfig.h
//  QBIM
//
//  Created by liunian on 14-3-14.
//  Copyright (c) 2014年 liunian. All rights reserved.
//

#ifndef QBIM_ProtocolConfig_h
#define QBIM_ProtocolConfig_h

#define SERVER_DOMAIN_IM_SOCKET     @"202.85.223.216"
#define kPort_IM_SOCKET             12345

#define SERVER_DOMAIN_IM_HTTP       @"http://imapi.qianbao666.com"
#define kPort_IM_HTTP               80

#define kAPI_SENDMESSAGE   URLSTRINGFORMAT(SERVER_DOMAIN_IM_HTTP,@"messages")
#define kAPI_SUBSCRIBE   URLSTRINGFORMAT(SERVER_DOMAIN_IM_HTTP,@"groups/subscribe")
#define kAPI_UNSUBSCRIBE   URLSTRINGFORMAT(SERVER_DOMAIN_IM_HTTP,@"groups/unsubscribe")

#define APPID                       @"1"
#define app_token                   @"657d9b7faa6a40a4abb5e00b5117ca45"


#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

/*
 1: Message Delivery Report : 消息状态报告
 2: Content Message List : 消息列表
 3: Response : 应答
 4: HearBeat Req : 心跳请求
 5: HearBeat Resp : 心跳应答
 6: Auth Request : 授权请求
 7: Sys CMD : 系统命令
 8: Sys Report : 系统报告
 */

/*
 I: packet seq number int32
 V: version
 CT: Create Timestamp
 T: Thread
 U: Message UUID
 S: Sender
 R: Receiver
 PT: Payload Type
 P: Payload
 M: Content Message List
 MT: Message Type
 ST: Message Stage
 EC: Error Code int
 EM: Error Message
 AT: Auth Type
 AP: Auth Payload
 QL: QoS Level
 */

typedef NS_ENUM(NSInteger, PacketType) {
    PacketTypeDeliveryReport        = 1,
    PacketTypeContentMessageList    = 2,
    PacketTypeResponse              = 3,
    PacketTypeHearBeatReq           = 4,
    PacketTypeHearBeatResp          = 5,
    PacketTypeAuthRequest           = 6,
    PacketTypeSysCMD                = 7,
    PacketTypeSysReport             = 8,
};

typedef NS_ENUM(NSInteger, PacketFormat) {
    PacketFormatPlain   = 0,
    PacketFormatGzip    = 1,
};

typedef NS_ENUM(NSInteger, PayloadType) {
    PayloadTypeBinary   = 0,
    PayloadTypeJSON     = 1,
};


typedef NS_ENUM(NSInteger, MTPacketType) {
    MTPacketTypeSys     = 1,
    MTPacketTypeGroup   = 2,
    MTPacketTypePublic  = 3,
    MTPacketTypePrivate = 4,
};

typedef NS_ENUM(NSInteger, PacketContentType) {
    PacketContentTypeNone   = 0,
    PacketContentTypeText   = 1,
    PacketContentTypeHtml   = 2,
    PacketContentTypeImage  = 3,
    PacketContentTypeVoice  = 4,
    PacketContentTypeSmiley = 5,
    PacketContentTypeJson   = 6,
};

typedef NS_ENUM(NSInteger, PacketSubtypeType) {
    PacketSubtypeTypeNone   = 0,
};

typedef NS_ENUM(NSInteger, AuthType) {
    AuthTypeNone            = 0,
    AuthTypeCasToken        = 1,
};

typedef NS_ENUM(NSInteger, SystemCommandLine) {
    SystemCommandLineDisconnect   = 1,
};

typedef NS_ENUM(NSInteger, SystemCommandDisconnectType) {
    SystemCommandDisconnectTypeAuthFailed               = -1,
    SystemCommandDisconnectTypeLoginOnAnotherDevice     = -2,
    SystemCommandDisconnectTypeServerBusy               = -3,
};

#endif
